package com.bwm.bwm007.main.activity;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;

import com.bwm.bwm007.R;
import com.bwm.bwm007.main.fragment.PictrueFragment;
import com.bwm.bwm007.main.view.scaleview.HackyViewPager;

public class ShowPicActivity extends FragmentActivity {

    private HackyViewPager viewPager;
    private int[] mPics = {R.mipmap.detail_show_1, R.mipmap.detail_show_2, R.mipmap.detail_show_3, R.mipmap.detail_show_4, R.mipmap.detail_show_5, R.mipmap.detail_show_6};

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_show_pic);
        initviews();
    }

    private void initviews() {
        viewPager = (HackyViewPager) findViewById(R.id.viewpager);
        ViewPagerAdapter adapter = new ViewPagerAdapter(this.getSupportFragmentManager());
        viewPager.setAdapter(adapter);
    }

    private class ViewPagerAdapter extends FragmentStatePagerAdapter {

        public ViewPagerAdapter(FragmentManager fm) {
            super(fm);
        }

        @Override
        public Fragment getItem(int position) {
            int show_resId = mPics[position];
            return new PictrueFragment(show_resId,position,6);
        }

        @Override
        public int getCount() {
            return mPics.length;
        }


    }
}
